import request from "@/utils/request";
import { FORM, INDEX } from "@/config/baseUrl";

// 查询任务中心列表
export function getTaskCenterList(data) {
  return request({
    url: FORM + "/task/missionCenter/list",
    method: "post",
    data,
  });
}

// 新增或保存任务中心
export function saveTask(data) {
  return request({
    url: FORM + "/task/missionCenter/addOrUpdate",
    method: "post",
    data,
  });
}

// 查询任务详情
export function getTaskDetail(id) {
  return request({
    url: FORM + "/task/missionCenter/detail",
    method: "get",
    params: { id },
  });
}

// 查询任务执行详情
export function getTaskStepDetail(missionCenterId) {
  return request({
    url: FORM + "/task/missionExecStep/list",
    method: "post",
    data: { missionCenterId },
  });
}

// 查询表单填写内容信息
export function getTaskContent(data) {
  return request({
    url: FORM + "/task/taskContent/queryTaskContent",
    method: "post",
    data,
  });
}

// 保存表单填写信息
export function saveTaskContent(data) {
  return request({
    url: FORM + "/task/taskContent/saveTaskContent",
    method: "post",
    data,
  });
}

// 查看执行内容
export function getTaskStepFormContent(id) {
  return request({
    url: FORM + "/task/missionExecStep/detail",
    method: "get",
    params: { id },
  });
}

// 查看任务对应的表单模板
export function getTaskTemplateByTaskId(id) {
  return request({
    url: FORM + "/task/missionCenter/queryTaskTemplateMode",
    method: "get",
    params: { id },
  });
}

// 下载表单上传的附件
export function getFile(id) {
  return request({
    url: FORM + "/task/taskContent/byte/down",
    method: "get",
    params: { id },
    responseType: "blob"
  });
}

// 导出任务列表
export function exportTaskList(data) {
  return request({
    url: FORM + "/task/missionCenter/export",
    method: "post",
    data,
    responseType: "blob",
  });
}

// 根据时间+指标配置Id获取指标值
export function getIndexValue(params) {
  return request({
    url: INDEX + "/value/getValueByTimeAndConfigId",
    method: "get",
    params,
  });
}